\(\int (3+b \sin (e+f x)) (c+d \sin (e+f x))^2 \, dx\) [672]

   Optimal result
   Rubi [A] (verified)
   Mathematica [A] (verified)
   Maple [A] (verified)
   Fricas [A] (verification not implemented)
   Sympy [B] (verification not implemented)
   Maxima [A] (verification not implemented)
   Giac [A] (verification not implemented)
   Mupad [B] (verification not implemented)

Optimal result

Integrand size = 23, antiderivative size = 104 \[ \int (3+b \sin (e+f x)) (c+d \sin (e+f x))^2 \, dx=\frac {1}{2} \left (2 b c d+3 \left (2 c^2+d^2\right )\right ) x-\frac {2 \left (9 c d+b \left (c^2+d^2\right )\right ) \cos (e+f x)}{3 f}-\frac {d (2 b c+9 d) \cos (e+f x) \sin (e+f x)}{6 f}-\frac {b \cos (e+f x) (c+d \sin (e+f x))^2}{3 f} \]

[Out]

1/2*(2*b*c*d+a*(2*c^2+d^2))*x-2/3*(3*a*c*d+b*(c^2+d^2))*cos(f*x+e)/f-1/6*d*(3*a*d+2*b*c)*cos(f*x+e)*sin(f*x+e)
/f-1/3*b*cos(f*x+e)*(c+d*sin(f*x+e))^2/f

Rubi [A] (verified)

Time = 0.07 (sec) , antiderivative size = 106, normalized size of antiderivative = 1.02, number of steps used = 2, number of rules used = 2, \(\frac {\text {number of rules}}{\text {integrand size}}\) = 0.087, Rules used = {2832, 2813} \[ \int (3+b \sin (e+f x)) (c+d \sin (e+f x))^2 \, dx=-\frac {2 \left (3 a c d+b \left (c^2+d^2\right )\right ) \cos (e+f x)}{3 f}+\frac {1}{2} x \left (a \left (2 c^2+d^2\right )+2 b c d\right )-\frac {d (3 a d+2 b c) \sin (e+f x) \cos (e+f x)}{6 f}-\frac {b \cos (e+f x) (c+d \sin (e+f x))^2}{3 f} \]

[In]

Int[(a + b*Sin[e + f*x])*(c + d*Sin[e + f*x])^2,x]

[Out]

((2*b*c*d + a*(2*c^2 + d^2))*x)/2 - (2*(3*a*c*d + b*(c^2 + d^2))*Cos[e + f*x])/(3*f) - (d*(2*b*c + 3*a*d)*Cos[
e + f*x]*Sin[e + f*x])/(6*f) - (b*Cos[e + f*x]*(c + d*Sin[e + f*x])^2)/(3*f)

Rule 2813

Int[((a_) + (b_.)*sin[(e_.) + (f_.)*(x_)])*((c_.) + (d_.)*sin[(e_.) + (f_.)*(x_)]), x_Symbol] :> Simp[(2*a*c +
 b*d)*(x/2), x] + (-Simp[(b*c + a*d)*(Cos[e + f*x]/f), x] - Simp[b*d*Cos[e + f*x]*(Sin[e + f*x]/(2*f)), x]) /;
 FreeQ[{a, b, c, d, e, f}, x] && NeQ[b*c - a*d, 0]

Rule 2832

Int[((a_) + (b_.)*sin[(e_.) + (f_.)*(x_)])^(m_)*((c_.) + (d_.)*sin[(e_.) + (f_.)*(x_)]), x_Symbol] :> Simp[(-d
)*Cos[e + f*x]*((a + b*Sin[e + f*x])^m/(f*(m + 1))), x] + Dist[1/(m + 1), Int[(a + b*Sin[e + f*x])^(m - 1)*Sim
p[b*d*m + a*c*(m + 1) + (a*d*m + b*c*(m + 1))*Sin[e + f*x], x], x], x] /; FreeQ[{a, b, c, d, e, f}, x] && NeQ[
b*c - a*d, 0] && NeQ[a^2 - b^2, 0] && GtQ[m, 0] && IntegerQ[2*m]

Rubi steps \begin{align*} \text {integral}& = -\frac {b \cos (e+f x) (c+d \sin (e+f x))^2}{3 f}+\frac {1}{3} \int (c+d \sin (e+f x)) (3 a c+2 b d+(2 b c+3 a d) \sin (e+f x)) \, dx \\ & = \frac {1}{2} \left (2 b c d+a \left (2 c^2+d^2\right )\right ) x-\frac {2 \left (3 a c d+b \left (c^2+d^2\right )\right ) \cos (e+f x)}{3 f}-\frac {d (2 b c+3 a d) \cos (e+f x) \sin (e+f x)}{6 f}-\frac {b \cos (e+f x) (c+d \sin (e+f x))^2}{3 f} \\ \end{align*}

Mathematica [A] (verified)

Time = 0.72 (sec) , antiderivative size = 88, normalized size of antiderivative = 0.85 \[ \int (3+b \sin (e+f x)) (c+d \sin (e+f x))^2 \, dx=\frac {6 \left (6 c^2+2 b c d+3 d^2\right ) (e+f x)-3 \left (4 b c^2+24 c d+3 b d^2\right ) \cos (e+f x)+b d^2 \cos (3 (e+f x))-3 d (2 b c+3 d) \sin (2 (e+f x))}{12 f} \]

[In]

Integrate[(3 + b*Sin[e + f*x])*(c + d*Sin[e + f*x])^2,x]

[Out]

(6*(6*c^2 + 2*b*c*d + 3*d^2)*(e + f*x) - 3*(4*b*c^2 + 24*c*d + 3*b*d^2)*Cos[e + f*x] + b*d^2*Cos[3*(e + f*x)]
- 3*d*(2*b*c + 3*d)*Sin[2*(e + f*x)])/(12*f)

Maple [A] (verified)

Time = 1.74 (sec) , antiderivative size = 92, normalized size of antiderivative = 0.88

method result size
parts \(a \,c^{2} x +\frac {\left (a \,d^{2}+2 c d b \right ) \left (-\frac {\sin \left (f x +e \right ) \cos \left (f x +e \right )}{2}+\frac {f x}{2}+\frac {e}{2}\right )}{f}-\frac {\left (2 a c d +c^{2} b \right ) \cos \left (f x +e \right )}{f}-\frac {b \,d^{2} \left (2+\sin ^{2}\left (f x +e \right )\right ) \cos \left (f x +e \right )}{3 f}\) \(92\)
parallelrisch \(\frac {\left (-3 a \,d^{2}-6 c d b \right ) \sin \left (2 f x +2 e \right )+b \,d^{2} \cos \left (3 f x +3 e \right )+\left (-24 a c d -12 c^{2} b -9 b \,d^{2}\right ) \cos \left (f x +e \right )+\left (6 a f x -8 b \right ) d^{2}-24 \left (-\frac {b x f}{2}+a \right ) c d +12 c^{2} \left (a f x -b \right )}{12 f}\) \(105\)
derivativedivides \(\frac {c^{2} a \left (f x +e \right )-2 a c d \cos \left (f x +e \right )+a \,d^{2} \left (-\frac {\sin \left (f x +e \right ) \cos \left (f x +e \right )}{2}+\frac {f x}{2}+\frac {e}{2}\right )-c^{2} b \cos \left (f x +e \right )+2 c d b \left (-\frac {\sin \left (f x +e \right ) \cos \left (f x +e \right )}{2}+\frac {f x}{2}+\frac {e}{2}\right )-\frac {b \,d^{2} \left (2+\sin ^{2}\left (f x +e \right )\right ) \cos \left (f x +e \right )}{3}}{f}\) \(115\)
default \(\frac {c^{2} a \left (f x +e \right )-2 a c d \cos \left (f x +e \right )+a \,d^{2} \left (-\frac {\sin \left (f x +e \right ) \cos \left (f x +e \right )}{2}+\frac {f x}{2}+\frac {e}{2}\right )-c^{2} b \cos \left (f x +e \right )+2 c d b \left (-\frac {\sin \left (f x +e \right ) \cos \left (f x +e \right )}{2}+\frac {f x}{2}+\frac {e}{2}\right )-\frac {b \,d^{2} \left (2+\sin ^{2}\left (f x +e \right )\right ) \cos \left (f x +e \right )}{3}}{f}\) \(115\)
risch \(a \,c^{2} x +\frac {a \,d^{2} x}{2}+c d x b -\frac {2 \cos \left (f x +e \right ) a c d}{f}-\frac {\cos \left (f x +e \right ) c^{2} b}{f}-\frac {3 \cos \left (f x +e \right ) b \,d^{2}}{4 f}+\frac {b \,d^{2} \cos \left (3 f x +3 e \right )}{12 f}-\frac {\sin \left (2 f x +2 e \right ) a \,d^{2}}{4 f}-\frac {\sin \left (2 f x +2 e \right ) c d b}{2 f}\) \(117\)
norman \(\frac {\left (c^{2} a +\frac {1}{2} a \,d^{2}+c d b \right ) x +\left (c^{2} a +\frac {1}{2} a \,d^{2}+c d b \right ) x \left (\tan ^{6}\left (\frac {f x}{2}+\frac {e}{2}\right )\right )+\left (3 c^{2} a +\frac {3}{2} a \,d^{2}+3 c d b \right ) x \left (\tan ^{2}\left (\frac {f x}{2}+\frac {e}{2}\right )\right )+\left (3 c^{2} a +\frac {3}{2} a \,d^{2}+3 c d b \right ) x \left (\tan ^{4}\left (\frac {f x}{2}+\frac {e}{2}\right )\right )+\frac {d \left (d a +2 c b \right ) \left (\tan ^{5}\left (\frac {f x}{2}+\frac {e}{2}\right )\right )}{f}-\frac {12 a c d +6 c^{2} b +4 b \,d^{2}}{3 f}-\frac {\left (4 a c d +2 c^{2} b \right ) \left (\tan ^{4}\left (\frac {f x}{2}+\frac {e}{2}\right )\right )}{f}-\frac {\left (8 a c d +4 c^{2} b +4 b \,d^{2}\right ) \left (\tan ^{2}\left (\frac {f x}{2}+\frac {e}{2}\right )\right )}{f}-\frac {d \left (d a +2 c b \right ) \tan \left (\frac {f x}{2}+\frac {e}{2}\right )}{f}}{\left (1+\tan ^{2}\left (\frac {f x}{2}+\frac {e}{2}\right )\right )^{3}}\) \(259\)

[In]

int((a+b*sin(f*x+e))*(c+d*sin(f*x+e))^2,x,method=_RETURNVERBOSE)

[Out]

a*c^2*x+(a*d^2+2*b*c*d)/f*(-1/2*sin(f*x+e)*cos(f*x+e)+1/2*f*x+1/2*e)-(2*a*c*d+b*c^2)/f*cos(f*x+e)-1/3*b*d^2/f*
(2+sin(f*x+e)^2)*cos(f*x+e)

Fricas [A] (verification not implemented)

none

Time = 0.29 (sec) , antiderivative size = 90, normalized size of antiderivative = 0.87 \[ \int (3+b \sin (e+f x)) (c+d \sin (e+f x))^2 \, dx=\frac {2 \, b d^{2} \cos \left (f x + e\right )^{3} + 3 \, {\left (2 \, a c^{2} + 2 \, b c d + a d^{2}\right )} f x - 3 \, {\left (2 \, b c d + a d^{2}\right )} \cos \left (f x + e\right ) \sin \left (f x + e\right ) - 6 \, {\left (b c^{2} + 2 \, a c d + b d^{2}\right )} \cos \left (f x + e\right )}{6 \, f} \]

[In]

integrate((a+b*sin(f*x+e))*(c+d*sin(f*x+e))^2,x, algorithm="fricas")

[Out]

1/6*(2*b*d^2*cos(f*x + e)^3 + 3*(2*a*c^2 + 2*b*c*d + a*d^2)*f*x - 3*(2*b*c*d + a*d^2)*cos(f*x + e)*sin(f*x + e
) - 6*(b*c^2 + 2*a*c*d + b*d^2)*cos(f*x + e))/f

Sympy [B] (verification not implemented)

Leaf count of result is larger than twice the leaf count of optimal. 199 vs. \(2 (97) = 194\).

Time = 0.15 (sec) , antiderivative size = 199, normalized size of antiderivative = 1.91 \[ \int (3+b \sin (e+f x)) (c+d \sin (e+f x))^2 \, dx=\begin {cases} a c^{2} x - \frac {2 a c d \cos {\left (e + f x \right )}}{f} + \frac {a d^{2} x \sin ^{2}{\left (e + f x \right )}}{2} + \frac {a d^{2} x \cos ^{2}{\left (e + f x \right )}}{2} - \frac {a d^{2} \sin {\left (e + f x \right )} \cos {\left (e + f x \right )}}{2 f} - \frac {b c^{2} \cos {\left (e + f x \right )}}{f} + b c d x \sin ^{2}{\left (e + f x \right )} + b c d x \cos ^{2}{\left (e + f x \right )} - \frac {b c d \sin {\left (e + f x \right )} \cos {\left (e + f x \right )}}{f} - \frac {b d^{2} \sin ^{2}{\left (e + f x \right )} \cos {\left (e + f x \right )}}{f} - \frac {2 b d^{2} \cos ^{3}{\left (e + f x \right )}}{3 f} & \text {for}\: f \neq 0 \\x \left (a + b \sin {\left (e \right )}\right ) \left (c + d \sin {\left (e \right )}\right )^{2} & \text {otherwise} \end {cases} \]

[In]

integrate((a+b*sin(f*x+e))*(c+d*sin(f*x+e))**2,x)

[Out]

Piecewise((a*c**2*x - 2*a*c*d*cos(e + f*x)/f + a*d**2*x*sin(e + f*x)**2/2 + a*d**2*x*cos(e + f*x)**2/2 - a*d**
2*sin(e + f*x)*cos(e + f*x)/(2*f) - b*c**2*cos(e + f*x)/f + b*c*d*x*sin(e + f*x)**2 + b*c*d*x*cos(e + f*x)**2
- b*c*d*sin(e + f*x)*cos(e + f*x)/f - b*d**2*sin(e + f*x)**2*cos(e + f*x)/f - 2*b*d**2*cos(e + f*x)**3/(3*f),
Ne(f, 0)), (x*(a + b*sin(e))*(c + d*sin(e))**2, True))

Maxima [A] (verification not implemented)

none

Time = 0.21 (sec) , antiderivative size = 112, normalized size of antiderivative = 1.08 \[ \int (3+b \sin (e+f x)) (c+d \sin (e+f x))^2 \, dx=\frac {12 \, {\left (f x + e\right )} a c^{2} + 6 \, {\left (2 \, f x + 2 \, e - \sin \left (2 \, f x + 2 \, e\right )\right )} b c d + 3 \, {\left (2 \, f x + 2 \, e - \sin \left (2 \, f x + 2 \, e\right )\right )} a d^{2} + 4 \, {\left (\cos \left (f x + e\right )^{3} - 3 \, \cos \left (f x + e\right )\right )} b d^{2} - 12 \, b c^{2} \cos \left (f x + e\right ) - 24 \, a c d \cos \left (f x + e\right )}{12 \, f} \]

[In]

integrate((a+b*sin(f*x+e))*(c+d*sin(f*x+e))^2,x, algorithm="maxima")

[Out]

1/12*(12*(f*x + e)*a*c^2 + 6*(2*f*x + 2*e - sin(2*f*x + 2*e))*b*c*d + 3*(2*f*x + 2*e - sin(2*f*x + 2*e))*a*d^2
 + 4*(cos(f*x + e)^3 - 3*cos(f*x + e))*b*d^2 - 12*b*c^2*cos(f*x + e) - 24*a*c*d*cos(f*x + e))/f

Giac [A] (verification not implemented)

none

Time = 0.31 (sec) , antiderivative size = 93, normalized size of antiderivative = 0.89 \[ \int (3+b \sin (e+f x)) (c+d \sin (e+f x))^2 \, dx=\frac {b d^{2} \cos \left (3 \, f x + 3 \, e\right )}{12 \, f} + \frac {1}{2} \, {\left (2 \, a c^{2} + 2 \, b c d + a d^{2}\right )} x - \frac {{\left (4 \, b c^{2} + 8 \, a c d + 3 \, b d^{2}\right )} \cos \left (f x + e\right )}{4 \, f} - \frac {{\left (2 \, b c d + a d^{2}\right )} \sin \left (2 \, f x + 2 \, e\right )}{4 \, f} \]

[In]

integrate((a+b*sin(f*x+e))*(c+d*sin(f*x+e))^2,x, algorithm="giac")

[Out]

1/12*b*d^2*cos(3*f*x + 3*e)/f + 1/2*(2*a*c^2 + 2*b*c*d + a*d^2)*x - 1/4*(4*b*c^2 + 8*a*c*d + 3*b*d^2)*cos(f*x
+ e)/f - 1/4*(2*b*c*d + a*d^2)*sin(2*f*x + 2*e)/f

Mupad [B] (verification not implemented)

Time = 8.26 (sec) , antiderivative size = 108, normalized size of antiderivative = 1.04 \[ \int (3+b \sin (e+f x)) (c+d \sin (e+f x))^2 \, dx=-\frac {\frac {3\,a\,d^2\,\sin \left (2\,e+2\,f\,x\right )}{2}-\frac {b\,d^2\,\cos \left (3\,e+3\,f\,x\right )}{2}+6\,b\,c^2\,\cos \left (e+f\,x\right )+\frac {9\,b\,d^2\,\cos \left (e+f\,x\right )}{2}+3\,b\,c\,d\,\sin \left (2\,e+2\,f\,x\right )-6\,a\,c^2\,f\,x-3\,a\,d^2\,f\,x+12\,a\,c\,d\,\cos \left (e+f\,x\right )-6\,b\,c\,d\,f\,x}{6\,f} \]

[In]

int((a + b*sin(e + f*x))*(c + d*sin(e + f*x))^2,x)

[Out]

-((3*a*d^2*sin(2*e + 2*f*x))/2 - (b*d^2*cos(3*e + 3*f*x))/2 + 6*b*c^2*cos(e + f*x) + (9*b*d^2*cos(e + f*x))/2
+ 3*b*c*d*sin(2*e + 2*f*x) - 6*a*c^2*f*x - 3*a*d^2*f*x + 12*a*c*d*cos(e + f*x) - 6*b*c*d*f*x)/(6*f)